import { Injectable } from '@nestjs/common';
import * as fs from 'fs';
@Injectable()
export class DeleteService {
     deleteall(path): void {
        let files = [];
        if (fs.existsSync(path)) {
            files = fs.readdirSync(path);
            files.forEach((file, index) => {
                const curPath = path + '/' + file;
                if (fs.statSync(curPath).isDirectory()) { // recurse
                    this.deleteall(curPath);
                } else { // delete file
                    fs.unlinkSync(curPath);
                }
            });
            fs.rmdirSync(path);
        }
    }
}